package my.senix.springfactories;

import com.google.common.collect.Maps;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;

import java.util.Map;

/**
 * Created by lhs on 2018/11/25.
 */
public class MyEnviromentProcessor implements EnvironmentPostProcessor {

    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {

        if (!environment.getPropertySources().contains("bootstrap")) {
            Map<String, Object> map = Maps.newHashMap();
            map.put("server.port", 55555);
            environment.getPropertySources().addFirst(new MapPropertySource("senix", map));
        }
    }
}
